<template>
	<div class="padding-across-10" v-loading="loading" element-loading-text="拼命加载中">
		<div class="card" style="width: 100%;">
			<div style="padding-bottom: 5px">
				<headerOpreate style="width: 50px" :opreate-datas="opreateDatas" v-on:executeAction="executeAction"></headerOpreate>
				<span>【注】由于数据上报存在延迟，请点击刷新按钮。</span>
			</div>
			<el-row :gutter="10">
				<el-col :span="12" v-for="item in tableData" style="margin-top: 5px">
					<div class="card-body">
						<img style="cursor: pointer;height: 200px;" title="点击查看高清大图" v-bind:src="item.savefile" @click="findImg(item)"/>
						<div class="detail">
							<dl>
								<dt style="margin-top: 0;">设备名：</dt>
								<dd style="margin-top: 0;">{{item.devicename}}</dd>
							</dl>
							<dl>
								<dt>设备码：</dt>
								<dd>{{item.sn}}</dd>
							</dl>
							<dl>
								<dt>检测设备类型：</dt>
								<dd v-if="item.detecttype == 'Projector'">投影仪</dd>
								<dd v-if="item.detecttype == 'Curtain'">幕布</dd>
								<dd v-if="item.detecttype == 'Sound'">音响</dd>
							</dl>
							<dl>
								<dt>检测时间：</dt>
								<dd>{{item.time}}</dd>
							</dl>
							<dl  v-if="item.detecttype == 'Projector'">
								<dt>标准值：</dt>
								<dd>亮度：{{item.standarddata.luminosity}}</dd>&nbsp;
								<dd>流明：{{item.standarddata.lumen}}</dd>
							</dl>
							<dl  v-if="item.detecttype == 'Curtain'">
								<dt>标准值：</dt>
								<dd>X值：{{item.standarddata.x}}</dd>&nbsp;
								<dd>Y值：{{item.standarddata.y}}</dd>
							</dl>
							<dl  v-if="item.detecttype == 'Projector'">
								<dt>实际值：</dt>
								<dd>{{item.realdata.luminosity}}</dd>
							</dl>
							<dl  v-if="item.detecttype == 'Curtain'">
								<dt>实际值：</dt>
								<dd>X值：{{item.realdata.x}}</dd>&nbsp;
								<dd>Y值：{{item.realdata.y}}</dd>
							</dl>
							<dl  v-if="item.detecttype == 'Sound'">
								<dt>实际音量值：</dt>
								<dd>{{item.realdata.volume}}</dd>
							</dl>
							<dl>
								<dt>检测结果：</dt>
								<dd>
									<el-tag v-if="item.result == 0" type="success">正常</el-tag>
									<el-tag v-if="item.result == 1" type="danger">异常</el-tag>
									<el-tag v-if="item.result == 2" type="warning">标定文件不存在</el-tag>
									<el-tag v-if="item.result == 3" type="warning">摄像头出错</el-tag>
									<el-tag v-if="item.result == 4" type="warning">投影机未添加</el-tag>
									<el-tag v-if="item.result == 5" type="warning">音量传感器未添加</el-tag>
								</dd>
							</dl>
						</div>
					</div>
				</el-col>
			</el-row>
		</div>
		<el-dialog :visible.sync="dialogImg" id="img-diglog" :show-close="false">
			<img style="width: 100%;height: 100%" v-bind:src="dialogImgUrl" />
		</el-dialog>
	</div>
</template>

<script>
	import $ from 'jquery';
	import { GloabFun,HttpServer } from '../../../../assets/js/common.js'
	import headerOpreate from '../../../../components/headerOpreate'
	import noImg from '../../../../assets/images/no_img.jpg'
	export default {
		components: {
			headerOpreate
		},
		data() {
			return {
				loading: false,
				isReload: false,
				imgUrl: '',
				tableData: [],
				multipleSelection: [],
				currentPage: 1,
				pageSize: 10,
				totalSize: 0,
				dialogImg: false,
				opreateDatas: [{
					size: "small",
					type: 'primary',
					icon: 'el-icon-eleg-icon_refresh el-icon--left',
					name: '刷新',
					action: 'reloadDatas'
				}
				]
			}
		},
		props: {
			templateObj: {
				type: Object,
				default: {}
			}
		},
		methods: {
			executeAction(action) {
				if(action) {
					this[action]();
				}
			},
			findImg(item) {
				this.dialogImgUrl = item.savefile;
				this.dialogImg = true;
			},
			reloadDatas (){
				this.getDatas();
			},
			getDatas() {
				this.loading = true;
				HttpServer.httpPost.call(this,'/Api/NCC/AutoDetectResult/ByCmdid',{cmdid: this.templateObj.cmdid, UserId: parseInt(GloabFun.getKeyId())}, function(response){}, function(response){
					this.loading = false;
					if(response.data.code === 0){
						response.data.info.forEach(function(item){
							if(item.savefile == ''){
								item.savefile = noImg;
							}
						})
						this.tableData = response.data.info;
					}else {
						this.$notify.error({
							title: '错误',
							message: response.data.msg,
							duration: 2500
						});
					}
				})
			}
		},
		created() {
			this.getDatas();
		}
	}
</script>
<style scoped>
	@import '../../../../assets/css/font-awesome-4.7.0/css/font-awesome.css';
</style>
<style lang="less" scope>
	.card {
		.card-body {
			border: 1px solid #E0E0E0;
			padding: 6px;
			display: flex;
			img {
				height: 200px;
			}
			.detail {
				margin-left: 20px;
				dl {
					font-size: 14px;
					clear: left;
					dt,
					dd {
						display: inline-block;
						margin-top: 12px;
					}
				}
			}
		}
		.detail-title {
			height: 31px;
			color: green;
		}
		.detail-body {
			font-size: 14px;
			section {
				margin-top: 20px;
			}
		}
	}
	#img-diglog {
		/*.el-dialog--small {
			width: auto !important;
		}
		.el-dialog__body {
			overflow: visible !important;
		}*/
		text-align: center;
		.el-dialog {
			background: none;
			box-shadow: none;
		}
		.el-dialog__body {
			overflow: visible !important;
		}
	}
</style>